<template>
  <el-card>
      <el-table
      max-height="500"
      :data="stores_list"
      style="width: 100%">
      <el-table-column
        label="地区"
        width="200">
        <template slot-scope="scope">
          <span v-html="scope.row.area"></span>
        </template>
      </el-table-column>
      <el-table-column
        label="店名"
        width="200">
        <template slot-scope="scope">
          <span v-html="scope.row.salesname"></span>
        </template>
      </el-table-column>
      <el-table-column
        label="地址"
        width="200">
        <template slot-scope="scope">
          <span v-html="scope.row.addr"></span>
        </template>
      </el-table-column>
      <el-table-column
        label="开业时间"
        width="200">
        <template slot-scope="scope">
          <span>{{ scope.row.opentime }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="图片"
        width="200">
        <template slot-scope="scope">
          <el-image :src="scope.row.img_url" width="10" height="10" class="head_pic"></el-image>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <!-- <el-button
            size="mini"
            @click="handleEdit(scope.$index, scope.row)">编辑</el-button> -->
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <el-row type="flex" justify="center">
      <!-- <el-pagination
        @current-change="changePage"
        :page-size="page.pageSize"
        :current-page="page.currentPage"
        style="margin-top:10px"
        background
        layout="prev,pager,next"
        :total="page.total"
      ></el-pagination> -->
    </el-row>
  </el-card>
</template>

<script>
import { getStore, deleteData } from "../../utils/api";
import moment from "moment";
export default {
  data() {
    return {
      activeName: "first",
      select: "",
      radio: 0, // 文章状态
      list: [],
      channels: [], // 定义一个频道数组
      value1: "",
      defaultImg: require("../../assets/img/404.png"),
      formData: {
        // 文章状态查询数组
        status: 5,
        channel_id: null,
        data: []
      },
      page: {
        total: 0,
        currentPage: 1,
        pageSize: 10
      },
      params: {
        type: ""
      },
      stores_list: [],
      deleteParams: {
        type: "salesroom",
        id: ""
      }
    };
  },
  filters: {
    dataFormat: function(val) {
      return moment(Number(val)).format("YYYY年MM月DD日");
    }
  },
  methods: {
    // 删除指定ID数据
    handleDelete(index, row) {
      this.deleteParams.id = row.room_id;
      this.$confirm("确认删除？").then(() => {
        deleteData(this.deleteParams).then(res => {
          res.status === "200" && this.$message("删除成功");
          this.stores_list = res.data.results;
        });
      });
    },
    // 标签切换
    handleClick(tab, event) {
      console.log(tab, event);
    },
    // 获取门店信息
    getStoreInfo() {
      getStore().then(res => {
        // console.log(res);
        this.stores_list = res.data.results;
        // this.page.total = res.data.results.length;
      });
    },
    changePage(newPage) {
      // 分页时要携带条件
      this.page.currentPage = newPage;
      // this.queryArticles();
    }
  },
  created() {
    // this.getArticles();
    // this.getChannels();
    this.getStoreInfo();
  }
};
</script>

<style lang="less" scoped>
// .article-item {
//   display: flex;
//   justify-content: space-between;
//   padding: 20px;
//   border-bottom: 1px slolid #f2f3f4;
//   .left {
//     display: flex;
//     .info {
//       display: flex;
//       flex-direction: column;
//       margin-left: 10px;
//       justify-content: space-around;
//     }
//     img {
//       width: 180px;
//       height: 100px;
//       border-radius: 10px;
//     }
//   }
//   .right {
//     display: flex;
//     align-items: center;
//   }
// }
</style>
